﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=1">
    <meta name="format-detection" content="telephone=no">
    <meta charset="UTF-8">
    <title>数组forEach</title>
    <<link rel="stylesheet" href="../css/bootstrap.css"/>
    <script src="../js/jquery-2.2.0.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>
</head>
<body>
    <h1>数组forEach</h1><br/>

    <div id="app">
        {{name}}
        <img src="../imgs/forEach.png">
    </div>
<script src="../js/vue-2.5.16.js"></script>
<script src="../node_modules/axios/dist/axios.js"></script>
<script src="../node_modules/lodash/lodash.js"></script>

<script>
    var app = new Vue({
        el:'#app',
        data:{
            name:'模版数据'
        },
        mounted(){
            let arr = [1,2,3,4,5];
            for(let i=0,len=arr.length;i<len;i++){
                console.log(arr[i]);
            }
            //除了背景图的arr，还有可能遍历对象，遍历对象可以使用Object.keys，它会把对象的key以['name',id]的形式遍历可以如下
            let obj = {name:'kyo',id:6};
            for(let key of Object.keys(obj)){
                console.log('key:'+key);
                console.log('value:'+obj[key]);
            }
        }
    });
</script>

</body>
</html>